package com.lankystar.logistucs.spring.dao.impl;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.lankystar.logistucs.spring.dao.IUserTypeDao;
import com.lankystar.logistucs.spring.entity.UserType;

@Repository
public class UserTypeDaoImpl extends BaseDaoImpl implements IUserTypeDao{

	@Autowired
	private SessionFactory sf;
	
	public Session getSession(){
		System.out.println("session userTypeimpl");
		return sf.getCurrentSession();
	}
	@Override
	public UserType selectUserTypeById(int userTypeId) {
		UserType userType = (UserType) getSession().get(UserType.class, userTypeId);
		return userType;
	}
	@Override
	public UserType selectUserTypeByUserKey(int userKey) {
		UserType userType = (UserType) getSession().createQuery("from UserType where userKey = ? ")
							.setInteger(0, userKey).uniqueResult();
		return userType;
	}

}
